<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>校园综合服务系统</title>
    <head>
        <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
        <script>
            $(document).ready(function(){
                $("form").submit(function(event){
                    event.preventDefault();
                    var sto = window.localStorage.getItem("username")
                    var data = $.parseJSON(sto) 
                    var sid = data.id
                    var formData = $(this).serialize() + "&id=" + sid;
                    $.post("http://localhost:80/user/change-pwd",formData,function (response){
                        var data = $.parseJSON(response)
                        if (data.code == "00000") {
                            alert("密码修改成功，重新登录")
                            window.localStorage.clear();
                            $(location).attr("href", "index.html")
                        } else {
                            alert("原密码错误或新旧密码不能相同")
                        }
                    });
                });
            });
        </script>
        </head>
    <style>
        .container {
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>修改密码</h1>
        <form action="#" method="post">
            原密码：<input type="password" name="orignPwd"><br>
            新密码：<input type="password" name="newPwd"><br>
            两次输入新密码：<input type="password" name="newPwdConfirm"><br>
            <input id="change" type="submit" value="修改密码">
        </form>
    </div>
    


</body>
</html>